import Page
from Page import Personal
from Base.Base import Base
from selenium.webdriver.common.by import By


class PersonalCarinfo(Base):
    """
     车辆信息
    """

    # TODO: 发动机号暂时无内容,无法获取

    def __init__(self, driver):
        Base.__init__(self, driver)

        # 左侧的home键
        self.carinfo_home_btn = (By.XPATH, Personal.RESOURCE_ID.format("ivHome"))

        # 左侧的返回键
        self.carinfo_back_btn = (By.XPATH, Personal.RESOURCE_ID.format('ivBack'))

        # 页面_变量名_元素类型
        # 车辆图片
        self.carinfo_car_image_img = (By.XPATH, Personal.RESOURCE_ID.format("frame_car_info"))

        # 车型名称
        self.carinfo_car_model_name_text = (By.XPATH, Personal.RESOURCE_ID.format("textView5"))
        # self.car_model_name_text = (By.XPATH, Page.TEXT.format("车型："))

        # 车型文案
        self.carinfo_car_content_text = (By.XPATH, Personal.RESOURCE_ID.format("models"))

        # 车架号名称
        self.carinfo_car_frame_name_text = (By.XPATH, Personal.RESOURCE_ID.format("textView7"))
        # self.carinfo_frame_name_text = (By.XPATH, Page.TEXT.format("车架号："))

        # 车架号内容
        self.carinfo_car_frame_content_text = (By.XPATH, Personal.RESOURCE_ID.format("chassis_number"))

        # 发动机号名称
        self.carinfo_car_engine_name_text = (By.XPATH, Personal.RESOURCE_ID.format("textView8"))
        # self.carinfo_engine_name_text = (By.XPATH, Page.TEXT.format("发动机号："))

        # 发动机号内容(目前获取不到,暂时无法使用)
        # self.carinfo_car_engine_content_text = (By.XPATH, Personal.RESOURCE_ID.format(("")))

        # ICCID名称
        self.carinfo_car_ICCID_name_text = (By.XPATH, Personal.RESOURCE_ID.format("textView18"))
        # self.carinfo_ICCID_name_text = (By.XPATH, Page.TEXT.format("ICCID："))

        # ICCID内容
        self.carinfo_car_ICCID_content_text = (By.XPATH, Personal.RESOURCE_ID.format("iccid_number"))

        # 车牌号按钮
        self.carinfo_car_number_name_btn = (By.XPATH, Personal.RESOURCE_ID.format("ll_car_plate_number"))

        # 车牌号名称
        self.carinfo_car_number_name_text = (By.XPATH, Personal.RESOURCE_ID.format("textView9"))
        # self.carinfo_number_name_text = (By.XPATH, Page.TEXT.format("车牌号："))

    def click_home(self):
        """
        点击左侧的home键

        :return:None
        """
        self.click_element(self.carinfo_home_btn)

    def click_back(self):
        """
        点击左侧的back键

        :return:None
        """
        self.click_element(self.carinfo_back_btn)

    def get_car_image(self):
        """
        获取车辆图片

        :return:获取元素
        """
        return self.find_element_o(self.carinfo_car_image_img)

    def get_car_model_name(self):
        """
        获取车型名称

        :return:获取元素
        """
        return self.find_element_o(self.carinfo_car_model_name_text)

    def get_car_content(self):
        """
        获取车型名称内容

        :return: 获取元素
        """
        return self.find_element_o(self.carinfo_car_content_text)

    def get_car_frame_name(self):
        """
        获取车架号名称

        :return: 获取元素
        """
        return self.find_element_o(self.carinfo_car_frame_name_text)

    def get_car_frame_content(self):
        """
        获取车架号内容

        :return: 获取元素
        """
        return self.find_element_o(self.carinfo_car_frame_content_text)

    def get_car_engine_name(self):
        """
        获取车架号名称

        :return: 获取元素
        """
        return self.find_element_o(self.carinfo_car_engine_name_text)

    def get_car_ICCID_name(self):
        """
        获取iccid名称

        :return: 获取元素
        """
        return self.find_element_o(self.carinfo_car_ICCID_name_text)

    def get_car_ICCID_content(self):
        """
        获取iccid内容

        :return: 获取元素
        """
        return self.find_element_o(self.carinfo_car_ICCID_content_text)

    def get_car_number_name(self):
        """
        获取车牌号名称

        :return: 获取元素
        """
        return self.find_element_o(self.carinfo_car_number_name_text)

    def click_car_number_name(self):
        """
        点击车牌号按钮

        :return: None
        """
        self.click_element(self.carinfo_car_number_name_btn)

    def is_display_personal_car_info(self):
        """
        是否存在新手引导界面

        :return: bool
        """
        return self.is_display(self.carinfo_car_model_name_text)

